package com.j2eefast.flowable.bpm.service;


import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmApplyoutlibraryEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmApplyoutlibraryMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 申请出库Service接口
 * @author: yhli
 * @date 2020-06-28 22:09
 */
@Service
public class bpmCrmApplyoutlibraryService extends ServiceImpl<bpmCrmApplyoutlibraryMapper,bpmCrmApplyoutlibraryEntity> {

	@Resource
	private bpmCrmApplyoutlibraryMapper bpmCrmApplyoutlibraryMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmApplyoutlibraryEntity> queryWrapper = new QueryWrapper<bpmCrmApplyoutlibraryEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String orderContractPrice = (String) params.get("orderContractPrice");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderContractPrice), "order_contract_price", orderContractPrice);
          String orderIsTax = (String) params.get("orderIsTax");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsTax), "order_is_tax", orderIsTax);
          String orderIsTransport = (String) params.get("orderIsTransport");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsTransport), "order_is_transport", orderIsTransport);
          String orderIsGuarantee = (String) params.get("orderIsGuarantee");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderIsGuarantee), "order_is_guarantee", orderIsGuarantee);
          String orderOtherProject = (String) params.get("orderOtherProject");
         queryWrapper.eq(ToolUtil.isNotEmpty(orderOtherProject), "order_other_project", orderOtherProject);
          String carStockId = (String) params.get("carStockId");
         queryWrapper.eq(ToolUtil.isNotEmpty(carStockId), "car_stock_id", carStockId);
          String carVin = (String) params.get("carVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(carVin), "car_vin", carVin);
          String carVehicle = (String) params.get("carVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(carVehicle), "car_vehicle", carVehicle);
          String carStockCost = (String) params.get("carStockCost");
         queryWrapper.eq(ToolUtil.isNotEmpty(carStockCost), "car_stock_cost", carStockCost);
          String approvalIsCross = (String) params.get("approvalIsCross");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalIsCross), "approval_is_cross", approvalIsCross);
             String approvalTime = (String) params.get("approvalTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalTime), "approval_time", approvalTime);
  		Page<bpmCrmApplyoutlibraryEntity> page = bpmCrmApplyoutlibraryMapper.selectPage(new Query<bpmCrmApplyoutlibraryEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmApplyoutlibraryEntity bpmCrmApplyoutlibraryEntity) {
		Page<bpmCrmApplyoutlibraryEntity> page = bpmCrmApplyoutlibraryMapper.findPage(new Query<bpmCrmApplyoutlibraryEntity>(params).getPage(), bpmCrmApplyoutlibraryEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmApplyoutlibraryByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmApplyoutlibraryById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmApplyoutlibrary(bpmCrmApplyoutlibraryEntity bpmCrmApplyoutlibrary){
        bpmCrmApplyoutlibrary.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmApplyoutlibrary);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmApplyoutlibraryById(bpmCrmApplyoutlibraryEntity bpmCrmApplyoutlibrary) {
		return updateById(bpmCrmApplyoutlibrary);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmApplyoutlibraryEntity getbpmCrmApplyoutlibraryById(String id){
		return getById(id);
	}
}
